<%--
  Created by IntelliJ IDEA.
  User: taofu
  Date: 2020/11/22
  Time: 19:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>

<head>
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css">
    <script src="${ctx}/layui/jquery.js"></script>
    <link rel="font" href="${ctx}/layui/font/iconfont.woff">
</head>

<body>

<div class="layui-layout layui-layout-admin">
    <div class="layui-header" id="nav-header">
        <div class="layui-logo">
            员工休假管理系统
        </div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">

            <%--      <li class="layui-nav-item">--%>
            <%--        <a href="javascript:;">其它系统</a>--%>
            <%--        <dl class="layui-nav-child">--%>
            <%--          <dd><a href="">邮件管理</a></dd>--%>
            <%--          <dd><a href="">消息管理</a></dd>--%>
            <%--          <dd><a href="">授权管理</a></dd>--%>
            <%--        </dl>--%>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <%--          <img src="http://t.cn/RCzsdCq" class="layui-nav-img">--%>
                    ${user.getSysUser().getUsername()}
                    <i class="layui-icon layui-icon-auz"></i>
                    ${user.getRole()}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="${ctx}/user/editPagee?userId=${user.getSysUser().getId()}">基本资料</a></dd>
                </dl>
            </li>

            <li class="layui-nav-item"><a href="${ctx}/login/index" onclick="logout()">退出</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item">
                    <dd><a href="${ctx}/home/welcomePage">首页</a></dd>
                </li>
                <c:if test="${user.getRoleId()!=1}">
                    <li class="layui-nav-item">
                        <a href="javascript:;">申请假期</a>

                        <dl class="layui-nav-child">
                            <dd><a href="${ctx}/apply/appListPage">我的申请</a></dd>
                            <dd><a href="${ctx}/apply/applicationPage">填写申请表</a></dd>
                        </dl>
                    </li>
                </c:if>
                <c:if test="${user.getRoleId()==1||user.getRoleId()==2}">
                    <li class="layui-nav-item">
                        <a href="javascript:;">我的事务<span class="layui-badge taskNum"></span></a>
                        <dl class="layui-nav-child">
                            <dd><a href="${ctx}/task/myTaskPage">待处理的事务<span class="taskNum layui-badge"></span></a>
                            <dd><a href="${ctx}/task/historyTaskPage">我已处理的</a>
                            </dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">员工管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="${ctx}/test/index">用户列表</a></dd>
                            <dd><a href="${ctx}/user/addPage">员工录入</a></dd>
                        </dl>
                    </li>
                </c:if>

                <li class="layui-nav-item">
                    <a href="javascript:;">更多</a>
                    <dl class="layui-nav-child">
                        <c:if test="${user.getRoleId()!=3}">
                            <dd><a href="">统计</a></dd>
                        </c:if>
                        <dd><a href="http://www.bing.com">必应</a></dd>
                        <dd><a href="http://www.baidu.com">百度</a></dd>
                    </dl>
                </li>

            </ul>
        </div>
    </div>

    <div class="layui-body" style="bottom: 0;">
        <!-- 内容主体区域 -->
        <iframe id="mainFrame" src="${ctx}/home/welcomePage" frameborder="0" width="100%" height="100%"></iframe>
    </div>

    <!-- <div class="layui-footer">
        © layui.com - 底部固定区域
    </div> -->
</div>

</body>
<script src="${ctx}/layui/layui.all.js"></script>
<script>
    $(document).ready(function () {
        $("dd > a").click(function (e) {
            e.preventDefault();
            $("#mainFrame").attr("src", $(this).attr("href"));
        });
    });
</script>
<script>
    layui.use("element", function () {

    })
    getMyTaskNum()
    renderMenu()

    function renderMenu() {

    }

    function logout() {
        $.ajax({
            url: "${ctx}/login/logout",
            success: res => {
                console.log(res)
            }
        })
    }

    function getMyTaskNum() {
        $.ajax({
            url: "${ctx}/task/getMyTaskNum",
            success: res => {
                if (res.data != "0") {
                    $(".taskNum").text(res.data)
                } else
                    $(".taskNum").css("display", "none")


            }
        })
    }
</script>

</html>
<style>

</style>